package com.xzx.shop_front_api.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xzx.shop_front_api.entity.Category;
import com.xzx.shop_front_api.entity.Goods;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * goods mapper
 */
@Mapper
public interface GoodsMapper {
    @Insert("INSERT INTO goods(goods_name, first_cate_id, second_cate_id, third_cate_id, sales_number, sale_price, main_image) VALUES (#{goodsName}, #{firstCateId}, #{secondCateId}, #{thirdCateId}, #{salesNumber}, #{salePrice}, #{mainImage})")
    int insert(Goods goods);

    @Select("SELECT * FROM goods WHERE id = #{id}")
    Goods selectById(Long id);

    @Delete("DELETE * FROM goods WHERE id = #{id}")
    int deleteById(Long id);

    @Select("SELECT *FROM goods")
    List<Goods> selectAll();
}
